package com.sne.airways.route.pojo;

import com.sne.airways.basecore.pojo.BaseProperties;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: 卞京帅{bjslogin@gmail.com}
 * Date: 12-11-20
 * Time: 下午10:32
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "EXP_COUNTRY")
@BatchSize(size=5)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class ExpCountry extends BaseProperties {

    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(length = 45)
    private String countryId;//国家id

    @Column(length = 30)
    private String countryCode;//国家代码

    @Column(length = 200)
    private String countryName;//名称

    @Column(length = 400)
    private String countryDesc;//描述

    private Integer status;

    @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY,mappedBy = "country",targetEntity = ExpAirPort.class)
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    private Set<ExpAirPort> portSet = new HashSet<ExpAirPort>();

    @Transient
    private String countryDetail;


    public String getCountryId() {
        return countryId;
    }

    public void setCountryId(String countryId) {
        this.countryId = countryId;
    }

    public String getCountryCode() {
        return countryCode;
    }

    public void setCountryCode(String countryCode) {
        this.countryCode = countryCode;
    }

    public String getCountryName() {
        return countryName;
    }

    public void setCountryName(String countryName) {
        this.countryName = countryName;
    }

    public String getCountryDesc() {
        return countryDesc;
    }

    public void setCountryDesc(String countryDesc) {
        this.countryDesc = countryDesc;
    }

    public Set<ExpAirPort> getPortSet() {
        return portSet;
    }

    public void setPortSet(Set<ExpAirPort> portSet) {
        this.portSet = portSet;
    }

    public String getCountryDetail() {
        return this.countryCode + "-" + this.countryName;
    }

    public void setCountryDetail(String countryDetail) {
        this.countryDetail = countryDetail;
    }
}
